package br.ucb.cm.config;

import br.ucb.cm.config.bean.Config;
import br.ucb.cm.config.bean.NewGameConfig;

public class GameInstance {
	private static GameInstance instance;
	private Config config;
	private NewGameConfig newGameConfig;
	
	public static GameInstance getInstance() {
		if(instance == null)
			instance = new GameInstance();
		return instance;
	}
	
	private GameInstance(){
		
	}
	
	public NewGameConfig getNewGameConfig() {
		return newGameConfig;
	}
	
	public void setNewGameConfig(NewGameConfig newGameConfig) {
		this.newGameConfig = newGameConfig;
	}
	
	public void loadConfig(Config config){
		setConfig(config);
	}
	
	public void loadNewGameConfig(NewGameConfig newConfig) {
		 setNewGameConfig(newConfig);
	}
	
	public void unloadConfig(){
		setConfig(null);
	}

	public Config getConfig() {
		return config;
	}
	public void setConfig(Config config) {
		this.config = config;
	}
	
	public void close(){
		config = null;
		newGameConfig = null;
		instance = null;
		System.gc();
	}
	
}
